using System;
using System.Collections.Generic;
using System.Text;

namespace Tools
{
    public enum MoveOffset { FromZero, FromCurrent, FromOtherLimit }
    public class Range
    {

        
        private long begin;
        private long end;

        public Range() {
            this.From = 0;
            this.Length = 0;
        }

        public Range(long from, long length) {
            this.From = from;
            this.Length = length;
        }

        public long Length {
            get {
                return this.To - this.From;
            }
            set {
                this.To = this.From + value;
            }
        }

        public long From {
            set {
                this.begin = value;
            }
            get {
                return this.begin;
            }
        }
        public long To
        {
            set
            {
                this.end = value;
            }
            get
            {
                return this.end;
            }
        }

        //publ
        public long moveBegining(long value, MoveOffset offset) {
            switch (offset) { 
                case MoveOffset.FromCurrent:
                    this.From += value;
                    break;
                case MoveOffset.FromOtherLimit:
                    this.From = this.To - value;
                    break;
                case MoveOffset.FromZero:
                    this.From = value;
                    break;
                default:
                    break;

            }
            return this.From;
        }

        public long moveEnd(long value, MoveOffset offset)
        {
            switch (offset)
            {
                case MoveOffset.FromCurrent:
                    this.To += value;
                    break;
                case MoveOffset.FromOtherLimit:
                    this.To = this.From + value;
                    break;
                case MoveOffset.FromZero:
                    this.To = value;
                    break;
                default:
                    break;

            }
            return this.To;
        }


    }
}
